package entity

import (
	"shqsoft.cn/pasnj/base"
	//"strconv"
	"time"

	"github.com/jinzhu/gorm"
)

//对私贷款认定分户情况
type IndiAccoDiviPl_EJFH struct {
	ID          int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	DSDT        *time.Time `gorm:"column:DSDT";type:date` //日期
	ACNO        string     `gorm:"column:ACNO"`
	BANO        string     `gorm:"column:BANO"`
	CANO        string     `gorm:"column:CANO"`
	KHMC        string     `gorm:"column:KHMC"`  //客户名称
	ZJHM        string     `gorm:"column:ZJHM"`  //证件号码
	KHJL1       string     `gorm:"column:KHJL1"` //客户经理1
	ZB1         int        `gorm:"column:ZB1"`   //占比1
	KHJL2       string     `gorm:"column:KHJL2"` //客户经理2
	ZB2         *int       `gorm:"column:ZB2"`   //占比2
	KHJL3       string     `gorm:"column:KHJL3"` //客户经理3
	ZB3         *int       `gorm:"column:ZB3";`  //占比3
	KHJL4       string     `gorm:"column:KHJL4"` //客户经理4
	ZB4         *int       `gorm:"column:ZB4";`  //占比4
	DRJG        string     `gorm:"column:DRJG"`  //导入结果
	ISTZ        string     `gorm:"column:ISTZ"`  //批量处理方式
	ISTZCaption string     `gorm:"-"`
}

//TableName 对私贷款认定分户情况
func (IndiAccoDiviPl_EJFH) TableName() string {
	return "T_INDI_CXPLRD_EJFH"
}
func (pl *IndiAccoDiviPl_EJFH) AfterFind() (err error) {
	if pl.ISTZ == "0" {
		pl.ISTZCaption = "批量处理未分配的储蓄客户"
	} else if pl.ISTZ == "1" {
		pl.ISTZCaption = "批量调整已分配的储蓄客户"
	}
	return
}

//导入后执行分户处理
func IndiAccoDiviPl_EJFHAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	ISTZ := params["ISTZ"]
	if ISTZ == "0" {
		tx.Exec("exec UP_INDI_DIVI_PL_CL_EJFH")
	} else if ISTZ == "1" {
		tx.Exec("exec UP_INDI_DIVI_PL_TZ_EJFH")
	}
	return nil
}

func IndiAccoDiviPl_EJFHEF() base.EntityFunc {
	return func() interface{} {
		entity := IndiAccoDiviPl_EJFH{}
		return &entity
	}
}
func IndiAccoDiviPl_EJFHESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []IndiAccoDiviPl_EJFH
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("IndiAccoDiviPl_EJFH", base.NewDefaultDao(IndiAccoDiviPl_EJFHEF(), IndiAccoDiviPl_EJFHESF(), nil))
	base.SetAfterCallBack("IndiAccoDiviPl_EJFH", IndiAccoDiviPl_EJFHAfterImport)
}
